//
//  gonggongbaoxiuViewController.m
//  wuyeviewcon
//
//  Created by dsdf on 16/1/27.
//  Copyright © 2016年 joey. All rights reserved.
//

#import "gonggongbaoxiuViewController.h"

@interface gonggongbaoxiuViewController ()

@end

@implementation gonggongbaoxiuViewController



- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
//
//    self.navigationController.navigationBar.barTintColor = [[UIColor alloc] initWithRed:230/255.0 green:55/255.0 blue:55/255.0 alpha:1.0];
//    
//    UIButton* button = [UIButton buttonWithType:UIButtonTypeCustom];
//    button.frame = CGRectMake(0, 0, 20, 20);
//    [button setBackgroundImage:[UIImage imageNamed:@"return@2x.png"] forState:UIControlStateNormal];
//    [button addTarget:self action:@selector(fanhui) forControlEvents:UIControlEventTouchUpInside];
//    UIBarButtonItem * rightItem = [[UIBarButtonItem alloc] initWithCustomView:button];
//    self.navigationItem.leftBarButtonItem = rightItem;
//    

    UIButton *button=[[UIButton alloc]init];
    button.frame=CGRectMake(0, 0, 375, 64);
    button.backgroundColor=[UIColor colorWithRed: 230/255.0 green:55/255.0 blue:55/255.0 alpha:1.0];
    [self.view addSubview:button];
    
    
 
    
    UIButton *button1=[[UIButton alloc]init ];//]WithFrame:CGRectMake(50, 50, 20, 20)];
    button1.frame=CGRectMake(22, 35, 20, 20);
    [button1 setBackgroundImage:[UIImage imageNamed:@"return@2x.png"] forState:UIControlStateNormal];
    [button1 addTarget:self action:@selector(fanhui:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button1];
    
    
    
    NSArray *arry=[[NSArray alloc]initWithObjects:@"公共报修",@"我的报修", nil];
    UISegmentedControl *sege=[[UISegmentedControl alloc]initWithItems:arry];
    sege.frame=CGRectMake(102, 29, 185, 27);
    sege.selectedSegmentIndex=0;
    sege.tintColor=[UIColor whiteColor];
    sege.backgroundColor=[UIColor redColor];
    //sege.momentary=YES;
    sege.segmentedControlStyle=UISearchBarStyleDefault;
    sege.layer.masksToBounds=YES;
    //[sege addTarget:selfaction:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged];
    [sege addTarget:self action:@selector(controlPressed:) forControlEvents:UIControlEventValueChanged];
    [self.view addSubview:sege];
    
    
    _gonggongbaoxiuView.alpha=1;
    _gonggongbaoxiuView2.alpha=0;
    
}
- (IBAction)fanhui:(id)sender {
    [self dismissModalViewControllerAnimated:YES];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

    -(void)controlPressed:(id)sender{
        
        
        
        UISegmentedControl *control = (UISegmentedControl *)sender;
        
    
            
            int x = control.selectedSegmentIndex;
        
        switch (x) {
            case 0:
                NSLog(@"1");
                _gonggongbaoxiuView.alpha=1;
                _gonggongbaoxiuView2.alpha=0;
                
                break;
                
            default:
                NSLog(@"2");
                _gonggongbaoxiuView.alpha=0;
                _gonggongbaoxiuView2.alpha=1;
                
                break;
        }
        
        
            
        }




/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
